<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('待检测列表列表')"/>
</head>
<body class="pear-container">
<div class="layui-card">
    <div class="layui-card-body">
        <form class="layui-form" action="">
            <div class="layui-form-item">
                <label class="layui-form-label">名称</label>
                <div class="layui-input-inline">
                    <input type="text" name="searchText" placeholder="" class="layui-input">
                </div>
                <button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="scaletab-query">
                    <i class="layui-icon layui-icon-search"></i>
                    查询
                </button>
                <button type="reset" class="pear-btn pear-btn-md">
                    <i class="layui-icon layui-icon-refresh"></i>
                    重置
                </button>
            </div>
        </form>
    </div>
</div>
<div class="layui-card">
    <div class="layui-card-body">
        <table id="scaletab-table" lay-filter="scaletab-table"></table>
    </div>
</div>
</body>



<script type="text/html" id="scaletab-bar">
    <button sa:hasPermission="gen:scaletab:edit" class="pear-btn pear-btn-primary pear-btn-sm" lay-event="edit" title="打印"><i class="layui-icon layui-icon-print"></i> 打印
    </button>

</script>



<script type="text/html" id="standardWeightCorrected-type">


    {{#if (d.standardWeightCorrected == { "v1":"10", "v2":"10", "v3":"8","v4": "-1"}) { }}
    <span class="layui-badge layui-bg-default-blue">10KG砝码预定参数</span>

    {{#if (d.standardWeightCorrected == { "v1":"10", "v2":"10", "v3":"8","v4": "-1"}) { }}
    <span class="layui-badge layui-bg-default-blue">20KG砝码预设值</span>
    {{# } }}
</script>


<script type="text/javascript" th:inline="javascript">
    var standardWeightCorrected_list = [[${@dict.getType('json')}]];
    var mpe1_list = [[${@dict.getType('E2_F1_F2_M1')}]];

    window.selectDictLabel=function(datas, value) {
        var actions = [];
        $.each(datas, function(index, dict) {
            if (dict.dictValue == ('' + value)) {
                var listClass = ("default"== dict.listClass) ? "" : "badge badge-" + dict.listClass;
                actions.push(sprintf("<span class='%s'>%s</span>", listClass, dict.dictLabel));
                return false;
            }
        });
        return actions.join('');
    }
    window.sprintf=function (str) {
        var args = arguments, flag = true, i = 1;
        str = str.replace(/%s/g, function () {
            var arg = args[i++];
            if (typeof arg === 'undefined') {
                flag = false;
                return '';
            }
            return arg;
        });
        return flag ? str : '';
    }
</script>



<th:block th:include="include :: footer"/>
<script>
    layui.use(['table', 'form', 'jquery'], function () {
        let table = layui.table;
        let form = layui.form;
        let $ = layui.jquery;
        let MODULE_PATH = rootPath+"/DetectionController/";
        let cols = [
            [
                {type: 'checkbox'},

                {title: 'id', field: 'id', align: 'left'},

                {title: '客户名称', field: 'customer', align: 'left'},

                {title: '主要标准器名称', field: 'mainstandard', align: 'center'},


                {title: '审核人', field: 'checkver', align: 'left'},


                {title: '准确度等级／MPE1', field: 'mpe1', align: 'center',templet:function(d){
                        return selectDictLabel(mpe1_list, d.mpe1);
                    }},

                {title: '创建时间', field: 'createtime', align: 'center'},
                {title: '操作', toolbar: '#scaletab-bar', align: 'center'}
            ]
        ]

        //table表单列表
        table.render({
            elem: '#scaletab-table',
            url: MODULE_PATH + 'listPrint',
            page: true,
            method: 'get',
            cols: cols,
            skin: 'line',
            toolbar: '#scaletab-toolbar',
            defaultToolbar: [{
                layEvent: 'refresh',
                icon: 'layui-icon-refresh',
            }, 'filter', 'print', 'exports']
        });

        //table图标事件绑定
        table.on('tool(scaletab-table)', function (obj) {
            if (obj.event === 'edit') {
                window.edit(obj);
            }
        });

        //table工具栏绑定
        table.on('toolbar(scaletab-table)', function (obj) {
            if (obj.event === 'refresh') {
                window.refresh();
            }
        });

        //查询按钮绑定
        form.on('submit(scaletab-query)', function (data) {
            table.reload('scaletab-table', {page: {curr: 1}, where: data.field})
            return false;
        });



        // //修改
        // window.edit = function (obj) {
        //     layer.open({
        //         type: 2,
        //         title: '砝码检测',
        //         shade: 0.1,
        //         area: ['1000px', '600px'],
        //         content: MODULE_PATH1 + 'edit/' + obj.data['id']
        //     });
        // }
        window.edit = function (obj) {
            window.location.href=MODULE_PATH + 'print/' + obj.data['id'];
        }




        //刷新按钮
        window.refresh = function () {
            table.reload('scaletab-table');
        }
    })
</script>
<script>
    window.addEventListener('pagehide', function () {
        const shouldRefresh = localStorage.getItem('shouldRefresh');
        if (shouldRefresh === 'true') {
            // 清除标识
            localStorage.removeItem('shouldRefresh');
            // 刷新页面
            location.reload();
        }
    });
</script>
</html>